package kz.kstu.aecdemo.facade.ejb.impl;

import kz.kstu.aec.model.AuthenticationData;
import kz.kstu.aec.model.Point2D;
import kz.kstu.aecdemo.business.entity.security.ECAccount;
import kz.kstu.aecdemo.business.server.api.AccountService;
import kz.kstu.aecdemo.facade.ejb.api.AccountFacade;

import javax.ejb.Stateless;
import javax.security.auth.login.AccountException;
import javax.security.auth.login.AccountNotFoundException;
import javax.security.auth.login.LoginException;
import java.math.BigInteger;

/**
 * @author Filipp_Stankevich
 *         created: 08.09.11 17:36
 */
@Stateless
public class AccountFacadeBean extends AbstractFacadeBean implements AccountFacade {

    @Override
    public void register(String login, Point2D publicKey) throws AccountException {
        getService(AccountService.class).register(login, publicKey);
    }

    @Override
    public BigInteger getAuthenticationNumber(String login) throws AccountNotFoundException {
        return getService(AccountService.class).getAuthenticationNumber(login);
    }

    public ECAccount login(AuthenticationData authenticationData) throws LoginException {
        return getService(AccountService.class).login(authenticationData);
    }

    @Override
    public void changePassword(String login, Point2D publicKey) throws AccountNotFoundException {
        getService(AccountService.class).changePassword(login, publicKey);
    }

    @Override
    public int getUserCount() {
         return getService(AccountService.class).getUserCount();
    }
}
